var xmlHttp;

function showEmp(emp_value)
{
    if(document.getElementById("emp_id").value!="-1")
    {
        xmlHttp=GetXmlHttpObject()
        if (xmlHttp==null)
        {
            alert ("Browser does not support HTTP Request")
            return
        }
        var url="getuser.jsp"
        url=url+"?emp_id="+emp_value

        xmlHttp.onreadystatechange=stateChanged
        xmlHttp.open("GET",url,true)
        xmlHttp.send(null)

    }
    else
    {
        alert("Please Select Employee Id");
    }
}

function stateChanged()
{
    document.getElementById("ename").value ="";
    document.getElementById("emp_id").value ="";
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {

        var showdata = xmlHttp.responseText;
        var strar = showdata.split(":");

        if(strar.length==1)
        {
            document.getElementById("emp_id").focus();
            alert("Please Select Employee Id");
            document.getElementById("ename").value =" ";
            document.getElementById("emp_id").value =" ";

        }
        else if(strar.length>1)
        {
            var strname = strar[1];
            document.getElementById("emp_id").value= strar[3];
            document.getElementById("ename").value= strar[1];
            document.getElementById("esurname").value= strar[2];
        }

    }
}

function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        //Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}